package br.edu.fasete.javaroad.model.architeture;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class Architeture implements Serializable {
	private static final long serialVersionUID = 1L;
	private String name;
	private String details;
	private String author;
	private String authorURL;
	private List<Component> components;
	private VariableList variables;

	public Architeture() {
		components = new ArrayList<Component>();
		variables = new VariableList();
	}
	
	public Architeture(String author, String authorURL, String details,
			String name) {
		this();
		this.author = author;
		this.authorURL = authorURL;
		this.details = details;
		this.name = name;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDetails() {
		return details;
	}
	public void setDetails(String details) {
		this.details = details;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public String getAuthorURL() {
		return authorURL;
	}
	public void setAuthorURL(String authorURL) {
		this.authorURL = authorURL;
	}
	public List<Component> getComponents() {
		return components;
	}
	public void setComponents(List<Component> components) {
		this.components = components;
	}
	public void addComponent(Component c) throws DuplicatedComponentException {
		if(!this.components.contains(c)){
			this.components.add(c);
		} else {
			throw new  DuplicatedComponentException(c.getName());
		}
	}
	public void removeComponent(Component c) {
		this.components.remove(c);
	}

	public VariableList getVariables() {
		return variables;
	}

	
	public void setVariables(VariableList variables) {
		this.variables = variables;
	}

	public void addVariable(Variable v) throws DuplicatedVariableException {
		this.variables.add(v);
	}
	
	public void removeVariable(Variable v) {
		this.variables.remove(v.getName());
	}
	
	public Collection<Variable> getVariableList() {
		return variables.getList();
	}
	
}
